package com.account.boot.commons.exception;

import org.slf4j.Logger;

import com.account.boot.commons.result.APIResultDO;

/**
 * 接口处理工具类
 * 
 * @author RoZz
 *
 */
public class APIExceptionUtils {
	
	public static void processException(APIResultDO apiResultDO, Throwable t, Logger logger) {
		if (t instanceof APIException) {
			APIException apiException = (APIException) t;
			apiResultDO.setCode(apiException.getResultCode());
			apiResultDO.setMsg(apiException.getErrorMessage());
			logger.error("发生异常啦! code:{},msg:{}", apiException.getResultCode(), apiException.getErrorMessage());
		} else {
			apiResultDO.setCode(APIResultDO.CODE_ERROR_EXCEPTION);
			apiResultDO.setMsg(APIResultDO.MSG_ERROR_EXCEPTION);
			logger.error("发生异常啦! {}", t);
		}
	}
}
